package phonedata;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowMap extends Mapper<LongWritable, Text, Text, FlowBean> {
    public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();//读取一行数据
        String str[] = line.split("\t");//因为英文字母是以“ ”为间隔的，因此使用“ ”分隔符将一行数据切成多个单词并存在数组中
        String phone = str[1];
        String status = str[str.length - 1];
        String flowDown = str[str.length - 2];
        String flowUp = str[str.length - 3];
        if ("200".equals(status)) {
            context.write(new Text(phone), new FlowBean(Long.parseLong(flowUp), Long.parseLong(flowDown)));
        }
    }

    public static void main(String[] args) {
        String line ="1363157985066 \t13726230503\t00-FD-07-A4-72-B8:CMCC\t120.196.100.82\ti02.c.aliimg.com\t\t24\t27\t2481\t24681\t200";
    }
}
